/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.liquidByte.trafficMustang.server.dataModel;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import org.liquidByte.trafficMustang.server.dataModel.enums.TrechoSituacao;

/**
 *
 * @author Alexandre
 */
@Entity
@Table(name = "trec_hist")
public class TrechoHistorico implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TrechoHistoricoPK trechoHistoricoPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "TREC_SIT_ID")
    @Enumerated(EnumType.ORDINAL)
    private TrechoSituacao trecSitId;
    @JoinColumn(name = "TREC_ID", referencedColumnName = "TREC_ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Trecho trecho;

    public TrechoHistorico() {
    }

    public TrechoHistorico(TrechoHistoricoPK trechoHistoricoPK) {
        this.trechoHistoricoPK = trechoHistoricoPK;
    }

    public TrechoHistorico(long trecId, Date trecHistDt) {
        this.trechoHistoricoPK = new TrechoHistoricoPK(trecId, trecHistDt);
    }

    public TrechoHistoricoPK getTrechoHistoricoPK() {
        return trechoHistoricoPK;
    }

    public void setTrechoHistoricoPK(TrechoHistoricoPK trechoHistoricoPK) {
        this.trechoHistoricoPK = trechoHistoricoPK;
    }

    public TrechoSituacao getTrecSitId() {
        return trecSitId;
    }

    public void setTrecSitId(TrechoSituacao trecSitId) {
        this.trecSitId = trecSitId;
    }

    public Trecho getTrecho() {
        return trecho;
    }

    public void setTrecho(Trecho trecho) {
        this.trecho = trecho;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (trechoHistoricoPK != null ? trechoHistoricoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TrechoHistorico)) {
            return false;
        }
        TrechoHistorico other = (TrechoHistorico) object;
        if ((this.trechoHistoricoPK == null && other.trechoHistoricoPK != null) || (this.trechoHistoricoPK != null && !this.trechoHistoricoPK.equals(other.trechoHistoricoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.liquidByte.trafficMustang.server.dataModel.TrechoHistorico[ trechoHistoricoPK=" + trechoHistoricoPK + " ]";
    }
    
}
